<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Spec::Rails::DSL::ViewBehaviourHelpers::ExampleMethods</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Spec::Rails::DSL::ViewBehaviourHelpers::ExampleMethods</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../../files/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view_rb.html">
                vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000030">render</a>&nbsp;&nbsp;
      <a href="#M000031">template</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000030" class="method-detail">
        <a name="M000030"></a>

        <div class="method-heading">
          <a href="#M000030" class="method-signature">
          <span class="method-name">render</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Renders a <a href="ExampleMethods.html#M000031">template</a> for a View
Spec, which then provides access to the result through the
<tt>response</tt>.
</p>
<h2>Examples</h2>
<pre>
  render('/people/list')
  render('/people/list', :helper =&gt; MyHelper)
  render('/people/list', :helpers =&gt; [MyHelper, MyOtherHelper])
  render(:partial =&gt; '/people/_address')
</pre>
<p>
See <a href="../ViewBehaviour.html">Spec::Rails::DSL::ViewBehaviour</a> for
more information.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000030-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb, line 23</span>
23:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
24:             <span class="ruby-identifier">options</span> = <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span> <span class="ruby-value">? </span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
25:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:template</span>] = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
26: 
27:             <span class="ruby-identifier">set_base_view_path</span>(<span class="ruby-identifier">options</span>)
28:             <span class="ruby-identifier">add_helpers</span>(<span class="ruby-identifier">options</span>)
29: 
30:             <span class="ruby-identifier">assigns</span>[<span class="ruby-identifier">:action_name</span>] = <span class="ruby-ivar">@action_name</span>
31: 
32:             <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path_parameters</span> = {
33:               <span class="ruby-identifier">:controller</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">derived_controller_name</span>(<span class="ruby-identifier">options</span>),
34:               <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">derived_action_name</span>(<span class="ruby-identifier">options</span>)
35:             }
36: 
37:             <span class="ruby-identifier">defaults</span> = { <span class="ruby-identifier">:layout</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span> }
38:             <span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">merge</span> <span class="ruby-identifier">options</span>
39: 
40:             <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">instance_variable_set</span> <span class="ruby-identifier">:@params</span>, <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">parameters</span>
41:             
42:             <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:initialize_current_url</span>
43: 
44:             <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-node">%{
45:               def controller_path
46:                 &quot;#{derived_controller_name(options)}&quot;
47:               end
48:               
49:               def controller_name
50:                 &quot;#{derived_controller_name(options).split('/').last}&quot;
51:               end
52:             }</span>
53: 
54:             <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:forget_variables_added_to_assigns</span>
55:             <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:render</span>, <span class="ruby-identifier">options</span>
56:             <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:process_cleanup</span>
57:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000031" class="method-detail">
        <a name="M000031"></a>

        <div class="method-heading">
          <a href="#M000031" class="method-signature">
          <span class="method-name">template</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
This provides the <a href="ExampleMethods.html#M000031">template</a>. Use
this to set mock expectations for dealing with partials
</p>
<h2>Example</h2>
<pre>
  describe &quot;/person/new&quot; do
    it &quot;should use the form partial&quot; do
      template.should_receive(:render).with(:partial =&gt; 'form')
      render &quot;/person/new&quot;
    end
  end
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000031-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb, line 70</span>
70:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">template</span>
71:             <span class="ruby-ivar">@controller</span>.<span class="ruby-identifier">template</span>
72:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>